package cirno.open.api.controller;

import cirno.open.api.common.BaseResponse;
import cirno.open.api.common.ResultUtils;
import cirno.open.api.model.vo.AccessVo;
import cirno.open.api.service.SignService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequiredArgsConstructor
@RequestMapping("/sign")
public class SignController {

    private final SignService signService;

    /**
     * 生成签名
     * @param accessVo
     * @return
     */
    @PostMapping
    public BaseResponse<Map<String,String>> getSign(@RequestBody AccessVo accessVo) {
        String accessKey = accessVo.getAccessKey();
        String secretKey = accessVo.getSecretKey();
        return ResultUtils.success(signService.genSign(accessKey,secretKey));
    }
}
